package com.jgraves.WikiToSpeech;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;

public class InputView extends Activity {

	private EditText mInputEditText;
	private Button mGoButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.inputview);

		//		mTts.setLanguage(Locale.UK);
		//		print("UK available: " + mTts.isLanguageAvailable(Locale.UK));


		mInputEditText = (EditText) findViewById(R.id.input_edittext);
		mGoButton = (Button) findViewById(R.id.go_button);

		String extra = getIntent().getStringExtra(Constants.EXTRA_INPUT_STRING);
		if(null!=extra){
			mInputEditText.setText(extra);
		}

		mGoButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(InputView.this,QuestionView.class);
				i.putExtra(Constants.EXTRA_INPUT_STRING, mInputEditText.getText().toString());
				i.putExtra(Constants.EXTRA_INPUT_TYPE, State.getDestinationType(mInputEditText.getText().toString()));
				startActivity(i);
			}
		});

		mInputEditText.setOnKeyListener(new OnKeyListener() {
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				// If the event is a key-down event on the "enter" button
				if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
						(keyCode == KeyEvent.KEYCODE_ENTER)) {
					return true;
				}
				return false;
			}
		});
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

}
